package
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class OuterButton extends MovieClip
	{
		private var number;
		private var type;
		private var typeNum;
		//private var elevators:Array;
		private var found:Found;
		private var state:Boolean;
		
		//private
		
		public function OuterButton(found:Found,pContainer:MovieClip,x:int,y:int,n:int,type:String)
		{
			reSet(x,y);
			
			number=n;
			this.type=type;
			if(type=="up")
			{
				this.gotoAndStop(1);
				typeNum=1;
			}
			else
			{
				this.gotoAndStop(2);
				typeNum=2;
			}
			
			state=false;
			//found;
			this.found=found;
			if(found==null)trace("NULL!");
			
			this.addEventListener(MouseEvent.CLICK,outermouseClick);
			pContainer.addChild(this);
		}
		
		public function reSet(x:int,y:int):void
		{
			this.x=x;
			this.y=y;
		}
		
		private function outermouseClick(e:MouseEvent):void
		{
			this.gotoAndStop(typeNum+2);
			if(state==false){
				if(type=="up"){
					found.addOuterTask(new Task(number,"up"));
				}
				else
					found.addOuterTask(new Task(number,"down"));
			state=true;
			}
			
		}
		
		public function setBack()
		{
			this.gotoAndStop(typeNum);
			state=false;
		}
		
		
	}
}